Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

370
Vistas
How to handle Uncaught Error: [nuxt] store/index.js should export a method that returns a Vuex instance

I have setup a default store in Nuxt in store/index.js as the documentation recommends. When I try to render my app I'm getting the following error:

Uncaught Error: [nuxt] store/index.js should export a method that returns a Vuex instance.

My store/index.js file looks like this:

import Vuex from 'vuex'
import Vue from 'vue'
import myModule from './myModule'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: () => ({

  }),
  mutations: {},
  actions: {},
  modules: {
    myModule: myModule
  }
})
export default store

How do I handle this?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You are exporting the Vuex store as a constant, you should export a default method that returns the Vuex store instance.

Your store/index.js file should look like this:

import Vuex from 'vuex'
import Vue from 'vue'
import myModule from './myModule'

Vue.use(Vuex)

export default () => new Vuex.Store({
  state: () => ({

  }),
  mutations: {},
  actions: {},
  modules: {
    myModule: myModule
  }
})
about 4 years ago · Juan Pablo Isaza Denunciar

0

I do have the following and it's working great.

import { test } from './modules/tasty_module'

const state = () => ({})
const mutations = {}
const actions = {}
const getters = {}

export default {
  state,
  mutations,
  getters,
  actions,
  modules: {
    testModule: test,
  },
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda